<%@ page language="java" contentType="text/html;charset=UTF-8" %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested"%>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack"%>
<%@ taglib uri="/WEB-INF/forecast-tags.tld" prefix="forecast"%>

<chiptrack:checkLogon sourcePage="projectSearch.do"/>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 java.util.ArrayList,
                 com.scalar.forecast.columnDisplay.ColumnMetaData"%>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<SCRIPT language="JavaScript">
    var errors1="";
    function openEditColumnWindow()
    {
        newWindow = window.open ('searchMetaData.do?action=edit&tableName=PROJSETUP','editColumnPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=auto,width=525 height=400,resizable=yes,left=300,top=130');
        newWindow.focus();
    }
    function changePassword()
    {
        newWindow = window.open ('/chiptrac_cavium/changePassword.do','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=no,width=500,height=270,resizable=no');
        newWindow.focus();
    }
    function search()
    {
        errors1="";

        var salesPersonSearchCondition = document.projectSearchForm['projectSearch.salesPersonSearchCriteria'].value;
        var projectSearchCondition = document.projectSearchForm['projectSearch.projectSearchCriteria'].value;
        var customerSearchCondition = document.projectSearchForm['projectSearch.customerSearchCriteria'].value;
		var odmSearchCondition = document.projectSearchForm['projectSearch.odmSearchCriteria'].value;

        if ( ( salesPersonSearchCondition == 'exactly' || salesPersonSearchCondition == 'startswith' )&& document.projectSearchForm['projectSearch.salesPerson'].value =="" )
        {
            errors1="<li>Please enter Sales Person Name";
        }
        if ( ( projectSearchCondition == 'exactly' || projectSearchCondition == 'startswith' )&& document.projectSearchForm['projectSearch.project'].value =="" )
        {
            errors1=errors1+"<br><li>Please enter Project Name";
        }
        if (  ( customerSearchCondition == 'exactly' ||  customerSearchCondition == 'startswith' ) && document.projectSearchForm['projectSearch.customer'].value =="" )
        {
            errors1=errors1+"<br><li>Please enter Customer Name";
        }
		if (  ( odmSearchCondition == 'exactly' ||  odmSearchCondition == 'startswith' ) && document.projectSearchForm['projectSearch.odm'].value == "" )
        {
            errors1=errors1+"<br><li>Please enter <bean:message key="label.sales.endCustomer"/> Name";
        }
        if( errors1 == "" )
        {
            document.projectSearchForm.action.value = "search";
            document.projectSearchForm.submit();
        }
        else
        {
            var pa = document.getElementById("errorsId");
            pa.innerHTML = "";
            pa = document.getElementById("infoId");
            pa.innerHTML = "";
            pa = document.getElementById("error");
            pa.innerHTML = errors1;
            pa = document.getElementById("searchResults");
            pa.innerHTML = "";
        }
    }
</SCRIPT>

<!-- Top Header Start-->
    <%
        String userTypeChiptrac = Constants.USER_TYPE_CHIPTRAC + "";
    %>
    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/header.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/extHeader.jsp" %>
    </logic:notEqual>
<!-- Top Header End-->

<html:form name="projectSearchForm" method="post"  action="/projectSearch.do" scope="session" type="com.scalar.forecast.projectSetup.forms.projectSearchForm" >

<TABLE cellSpacing=0 cellPadding=0 width="100%" border="0">
  <TBODY>
  <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
<!-- Side Navigation start -->
    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/marketing/marketing_menu.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/forecast/external_forecast_menu.jsp" %>
    </logic:notEqual>
    </TD>
<!-- end of the side navigations -->
    <TD bgcolor="#ffffff">
        <IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
        <TD valign="top" width="100%">

        <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
        <BR>
<!-- from here your body starts -->
        <center><span class="NArialW">Projects List</span></center>

        <TABLE cellSpacing=0 cellPadding=0 width="95%" align="center" border="0">
            <TBODY>
                <TR><TD colspan =7 align="left" class='NArialL'><font styleClass="NArialL" id="message1" color="green"  />&nbsp;</font></TD></TR>
                <TR><TD colspan =7 align="left" class='NArialL'><font styleClass="NArialL" id="error" color="red"  />&nbsp;</font></TD></TR>
                <TR><TD colspan =7 class="NArialL" id="infoId"><chiptrack:info styleClass="NArialL" /></TD></TR>
                <TR><TD colspan =7 class="NArialL" id="errorsId"><chiptrack:errors styleClass="NArialL" /></TD></TR>
                <TR><TD colspan =7 class="NArialL"><chiptrack:messages type="info" styleClass="NArialL" /></TD></TR>
                <TR>
                    <TD>
                      <nested:nest property="projectSearch">
                        <TABLE cellSpacing=0 cellPadding=2 width="100%" align="center"  border=0>
                        <TBODY>
                            <TR> <TD class=NArialL width="100%" colSpan=7><FONT id=message color="#ff0000"></FONT></TD></TR>
                            <TR>
                                <TD width="15%" align="left" nowrap><FONT class=NArialL>Sales Person:</FONT></TD>
                                <TD width="25%" align="left"><nested:text name="projectSearch"  property="salesPerson" styleClass="txfield" size="25" maxlength="50" /></TD>
                                <TD align=left width="10%">
                                    <nested:select name="projectSearch" styleClass="txfield" property="salesPersonSearchCriteria">
                                        <html:option value="contains">Contains</html:option>
                                        <html:option value="exactly">Exactly</html:option>
                                        <html:option value="startswith">Startswith</html:option>
                                    </nested:select>
                                </TD>
                                <TD>&nbsp;</TD>
                                <TD align=left width="15%"><FONT class=NArialL>Project:</FONT></TD>
                                <TD width="25%"><nested:text name="projectSearch" property="project" styleClass="txfield" size="25" maxlength="100" /></TD>
                                <TD align=left width="10%">
                                    <nested:select name="projectSearch" styleClass="txfield" property="projectSearchCriteria">
                                        <html:option value="contains">Contains</html:option>
                                        <html:option value="exactly">Exactly</html:option>
                                        <html:option value="startswith">Startswith</html:option>
                                    </nested:select>
                                </TD>
                            </TR>
                            <TR>
                                <TD width="15%" align="left" nowrap><FONT class=NArialL>Customer:</FONT></TD>
                                <TD width="25%" align="left"><nested:text name="projectSearch"  property="customer" styleClass="txfield" size="25" maxlength="50" /></TD>
                                <TD align=left width="10%">
                                    <nested:select name="projectSearch" styleClass="txfield" property="customerSearchCriteria">
                                        <html:option value="contains">Contains</html:option>
                                        <html:option value="exactly">Exactly</html:option>
                                        <html:option value="startswith">Startswith</html:option>
                                    </nested:select>
                                </TD>
                                <TD>&nbsp;</TD>
                                <TD align=left width="15%" nowrap><FONT class=NArialL><bean:message key="label.sales.endCustomer"/>:</FONT></TD>
                                <TD width="25%"><nested:text name="projectSearch" property="odm" styleClass="txfield" size="25" maxlength="100" /></TD>
                                <TD align=left width="10%">
                                    <nested:select name="projectSearch" styleClass="txfield" property="odmSearchCriteria">
                                        <html:option value="contains">Contains</html:option>
                                        <html:option value="exactly">Exactly</html:option>
                                        <html:option value="startswith">Startswith</html:option>
                                    </nested:select>
                                </TD>
                            </TR>

                            <TR> <TD width="100%" colSpan=7>&nbsp;</TD></TR>
                            <TR>
                                <TD align=middle width="100%" colSpan=7>
                                  <a href="javascript:search();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17"  onmouseover="window.status='Click here to Search for Project';return true" onmouseout="window.status='';return true" title="Click here to Search for Project" ></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                  <a href="javascript:document.projectSearchForm.reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"  onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset" ></a>
                                </TD>
                            </TR>
                        </TBODY>
                        </TABLE>
                        </nested:nest>
                    </TD>
                </TR>
                <TR> <TD><IMG height=10 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></TD></TR>
                <TR>
                      <TD>
                        <TABLE borderColor="#FFFFFF" width="100%" align=right border=2>
                        <TBODY>
                             <TR align=middle>
                                    <TD colspan=4 class="NArialL" align=left> To Setup new Project, please <A href='<%= chipTracContext%>/projectSetup.do?action=new' styleClass="leftsection" onmouseover="window.status='Click here to setup new Project';return true" onmouseout="window.status='';return true" title="Click here to setup new Project" >click here</A></TD>
                             </TR>
                        </TBODY>
                        </TABLE>
                      </TD>
                </TR>
                <TR>
                      <TD id="searchResults">
                        <TABLE borderColor="#FFFFFF" width="100%" align=right border=2>
                        <TBODY>
                        <logic:equal name="showList" value="true">
                            <TR align=middle>
                                <TD colspan=4 class=NArialL> <A href="javascript:openEditColumnWindow()" onmouseover="window.status='Click here to Edit Column Display';return true" onmouseout="window.status='';return true" title="Click here to Edit Column Display">[ Edit Column Display ] </A></TD>
                                <TD colspan=2 align="right" class="NArialL"><forecast:PageNumbers url="/projectSearch.do?action=nextPage"/></TD>
                            </TR>
                            <forecast:projectSearchResults/>
                         </logic:equal>
                            <TR>
                                <TD class=NArialL colSpan=3><IMG height=50 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></TD>
                            </TR>

                        </TBODY>
                        </TABLE>
                      </TD>
                </TR>

            </TBODY>
        </TABLE>
        <input type="hidden" name="action" value="">
        </html:form>
    </TD>
<!-- till here -->
    <TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
  </TR>
  </TBODY>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</BODY>
</HTML>
